package com.example.controller;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.example.pojo.Users;



/**
 * SpringBoot 表单数据校验
 *
 *
 */
@Controller
public class UsersController {

	@RequestMapping("/addUser")
	public String showPage(){
		return "add";
	}
	
	/**
	 * 完成用户添加
	 */
	@RequestMapping("/save")
	public String saveUser(@ModelAttribute("aa") @Valid Users users,BindingResult result){
		if(result.hasErrors()){
			return "add";
		}
		System.out.println(users);
		return "ok";
	}
}
